//
//  QiNiuApiManager.h
//  PetExchange
//
//  Created by a on 2021/2/26.
//

#import <Foundation/Foundation.h>
#import <Qiniu/QiniuSDK.h>
NS_ASSUME_NONNULL_BEGIN

@interface QiNiuApiManager : NSObject

/**
 七牛上传所需的token   服务端获取
 */
@property (nonatomic,copy)  NSString  *upToken;

/**
 七牛前面需要拼接的server
 */
@property (nonatomic , copy)  NSString  *qiniuServerUrl;

@property (nonatomic , strong)  QNUploadManager *upManager ;
/**
 七牛获取token 成功
 */
@property (nonatomic, copy) void (^getTokenSuccessBlock)();

+(QiNiuApiManager *)shareManager;



/**
 上传文件

 @param filePath 文件z地址
 @param key 图片的key
 @param upFinsh 上传成功
 @param failInfo 失败
 @param upProgress 上传进度
 */
- (void)uploadWithFilePath:(NSString *)filePath andUpKey:(NSString *)key andUpFail:(void (^)(QNResponseInfo *))failInfo andUpSuccess:(void(^)(NSDictionary *infoDict))upFinsh andUpLoadProgress:(void(^)(float progress))upProgress;
/**
 上传单个图片
 
 @param key 图片的key
 @param upImage 上传的图片
 @param upFinsh 上传成功
 @param failInfo 失败
 @param upProgress 上传进度
 */
- (void)upLoadImageWithUploadKey:(NSString *)key andImage:(UIImage *)upImage andFinshInfo:(void(^)(NSDictionary *infoDict))upFinsh andUpFail:(void (^)(QNResponseInfo * fail))failInfo andUpLoadProgress:(void(^)(float progress))upProgress;



/**
 上传图片或视频
 
 @param phAsset 上传的素材
 @param key 上传到七牛所需要的key
 @param upFinsh 上传成功的回调
 @param failInfo 上传失败的信息   具体看 QNResponseInfo 里面的属性
 @param upProgress 上传进度
 */
- (void)upLoadPHAsset:(PHAsset *)phAsset andUpKey:(NSString *)key andUpFail:(void (^)(QNResponseInfo *))failInfo andUpSuccess:(void(^)(NSDictionary *infoDict))upFinsh andUpLoadProgress:(void(^)(float progress))upProgress;

- (void)getQiNiuToken;


/**
 生成图片上传key

 @return
 */
+ (NSString *)getImageKeyWithType:(NSString *)tpye;

/**
 生成视频上传key
 
 @return
 */
+ (NSString *)getVideoKey;

/**
 生成音频上传key
 
 @return
 */
+ (NSString *)getVoiceKey;


@end

NS_ASSUME_NONNULL_END
